<template>
    <view>
        <view class="main">
            <view class="form noLabel">
                <uni-forms :modelValue="ruleForm" :rules="rules" ref="ruleForm" label-width="0" validateTrigger="blur">
                    <uni-forms-item name="mold">
                        <view class="radio">
                            <uni-data-checkbox v-model="ruleForm.mold" :localdata="radioList" @change="moldChange" />
                        </view>
                    </uni-forms-item>
                    <uni-forms-item name="mold_name" v-if="ruleForm.mold == 1">
                        <view class="select leftLine">
                            <view class="fl"><text class="red">*</text>{{$lang('选择询价单')}}：</view>
                            <view class="fr">
                                <input type="text" v-model="ruleForm.mold_name" :placeholder="$lang('请选择询价单编号')">
                                <image src="../../static/images/icon13.png"></image>
                                <view class="hideBox" @click="purchaseInternalInquiryListFun(1)"></view>
                            </view>
                        </view>
                    </uni-forms-item>
                    <uni-forms-item name="mold_name" v-else>
                        <view class="select leftLine">
                            <view class="fl"><text class="red">*</text>{{$lang('关联采购单号')}}：</view>
                            <view class="fr">
                                <input type="text" v-model="ruleForm.mold_name" :placeholder="$lang('请选择采购单号')">
                                <image src="../../static/images/icon13.png"></image>
                                <view class="hideBox" @click="internalListFun(4)"></view>
                            </view>
                        </view>
                    </uni-forms-item>
                    <uni-forms-item name="order_name">
                        <view class="select leftLine">
                            <view class="fl">{{$lang('关联订单号')}}：</view>
                            <view class="fr">
                                <input type="text" v-model="ruleForm.order_name" :placeholder="$lang('请选择订单号')">
                                <image src="../../static/images/icon13.png"></image>
                                <view class="hideBox" @click="purchaseOrderListFun(2)"></view>
                            </view>
                        </view>
                    </uni-forms-item>
                    <uni-forms-item name="code">
                        <view class="select leftLine">
                            <view class="fl"><text class="red">*</text>{{$lang('采购单编码')}}：</view>
                            <view class="fr">
                                <input type="text" v-model="ruleForm.code" :placeholder="$lang('请输入采购单编码')">
                            </view>
                        </view>
                    </uni-forms-item>
                    <view class="table" v-if="ruleForm.list.length > 0">
                        <uni-table border :emptyText="$lang('暂无数据')" type="selection">
                            <uni-tr class="tableHead">
                                <uni-th align="center" v-for="(item,index) in tableColumn" :key="index">{{$lang(item.label)}}</uni-th>
                                <uni-th align="center" v-if="ruleForm.list.length > 1">{{$lang('操作')}}</uni-th>
                            </uni-tr>
                            <uni-tr v-for="(item,index) in ruleForm.list" :key="index">
                                <uni-td align="center" v-for="(data,dataIndex) in tableColumn" :key="dataIndex">
                                    <text v-if="data.value == 'index'">{{index + 1}}</text>
                                    <view v-else-if="data.value == 'image'">
                                        <image :src="baseUrl + item[data.value]" style="width: 100rpx;height: 100rpx;"></image>
                                    </view>
                                    <view v-else-if="data.value == 'num'">
                                        <uni-forms-item :name="'list.' + index + '.num'" :rules="rules.required.rules">
                                            <uni-easyinput v-model="item.num" :placeholder="$lang('请输入')" />
                                        </uni-forms-item>
                                    </view>
                                    <view v-else-if="ruleForm.mold == 1">
                                        <view v-if="data.value == 'size'">
                                            <uni-forms-item :name="'list.' + index + '.size'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.size" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'unit'">
                                            <uni-forms-item :name="'list.' + index + '.unit'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.unit" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'before_unit_price'">
                                            <uni-forms-item :name="'list.' + index + '.before_unit_price'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.before_unit_price" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'purchase_unit_price'">
                                            <uni-forms-item :name="'list.' + index + '.purchase_unit_price'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.purchase_unit_price" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'all_price'">
                                            <uni-forms-item :name="'list.' + index + '.all_price'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.all_price" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'volume'">
                                            <uni-forms-item :name="'list.' + index + '.volume'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.volume" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'freight'">
                                            <uni-forms-item :name="'list.' + index + '.freight'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.freight" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'estimated_purchase_price'">
                                            <uni-forms-item :name="'list.' + index + '.estimated_purchase_price'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.estimated_purchase_price" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'gross_margin'">
                                            <uni-forms-item :name="'list.' + index + '.gross_margin'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.gross_margin" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'system_lowest_selling_price'">
                                            <uni-forms-item :name="'list.' + index + '.system_lowest_selling_price'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.system_lowest_selling_price" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'product_attributes'">
                                            <uni-forms-item :name="'list.' + index + '.product_attributes'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.product_attributes" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'product_ownership_id'">
                                            <uni-forms-item :name="'list.' + index + '.product_ownership_name'" :rules="rules.required.rules">
                                                <view style="position: relative">
                                                    <uni-easyinput v-model="item.product_ownership_name" :placeholder="$lang('请选择')" />
                                                    <view class="hideBox" @click="productOwnershipOtherFun(3,index)"></view>
                                                </view>
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'deliveryday'">
                                            <uni-forms-item :name="'list.' + index + '.deliveryday'">
                                                <uni-easyinput v-model="item.deliveryday" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'loadingday'">
                                            <uni-forms-item :name="'list.' + index + '.loadingday'">
                                                <uni-easyinput v-model="item.loadingday" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'shipping_cycle'">
                                            <uni-forms-item :name="'list.' + index + '.shipping_cycle'">
                                                <uni-easyinput v-model="item.shipping_cycle" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'customs_clearance_and_sample_production'">
                                            <uni-forms-item :name="'list.' + index + '.customs_clearance_and_sample_production'">
                                                <uni-easyinput v-model="item.customs_clearance_and_sample_production" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'delivery_cycle'">
                                            <uni-forms-item :name="'list.' + index + '.delivery_cycle'">
                                                <uni-easyinput v-model="item.delivery_cycle" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'sellable_inventory'">
                                            <uni-forms-item :name="'list.' + index + '.sellable_inventory'">
                                                <uni-easyinput v-model="item.sellable_inventory" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'number_of_maintenance_warehouses'">
                                            <uni-forms-item :name="'list.' + index + '.number_of_maintenance_warehouses'">
                                                <uni-easyinput v-model="item.number_of_maintenance_warehouses" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'last_delivery_time'">
                                            <uni-forms-item :name="'list.' + index + '.last_delivery_time'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.last_delivery_time" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'sales_since_last_arrival'">
                                            <uni-forms-item :name="'list.' + index + '.sales_since_last_arrival'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.sales_since_last_arrival" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'unfinished_order_sales'">
                                            <uni-forms-item :name="'list.' + index + '.unfinished_order_sales'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.unfinished_order_sales" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'quantity_in_transit'">
                                            <uni-forms-item :name="'list.' + index + '.quantity_in_transit'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.quantity_in_transit" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'purchase_date_in_transit'">
                                            <uni-forms-item :name="'list.' + index + '.purchase_date_in_transit'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.purchase_date_in_transit" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'expected_arrival_time_during_transit'">
                                            <uni-forms-item :name="'list.' + index + '.expected_arrival_time_during_transit'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.expected_arrival_time_during_transit" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'safety_stock_quantity'">
                                            <uni-forms-item :name="'list.' + index + '.safety_stock_quantity'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.safety_stock_quantity" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'estimate_monthly_sales_volume'">
                                            <uni-forms-item :name="'list.' + index + '.estimate_monthly_sales_volume'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.estimate_monthly_sales_volume" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'one_data'">
                                            <uni-forms-item :name="'list.' + index + '.one_data'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.one_data" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'two_data'">
                                            <uni-forms-item :name="'list.' + index + '.two_data'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.two_data" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'three_data'">
                                            <uni-forms-item :name="'list.' + index + '.three_data'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.three_data" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'four_data'">
                                            <uni-forms-item :name="'list.' + index + '.four_data'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.four_data" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'five_data'">
                                            <uni-forms-item :name="'list.' + index + '.five_data'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.five_data" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'six_data'">
                                            <uni-forms-item :name="'list.' + index + '.six_data'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.six_data" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                        <view v-else-if="data.value == 'memo'">
                                            <uni-forms-item :name="'list.' + index + '.memo'" :rules="rules.required.rules">
                                                <uni-easyinput v-model="item.memo" :placeholder="$lang('请输入')" />
                                            </uni-forms-item>
                                        </view>
                                    </view>
                                    <text v-else>{{item[data.value]}}</text>
                                </uni-td>
                                <uni-td align="center" v-if="ruleForm.list.length > 1">
                                    <view class="uni-group" style="width: 150rpx">
                                        <!--                                        <button class="text-btn" size="mini" type="primary">修改</button>-->
                                        <button class="text-btn" size="mini" type="warn">删除</button>
                                    </view>
                                </uni-td>
                            </uni-tr>
                        </uni-table>
                    </view>
                    <view class="info" v-if="supplier">
                        <view class="h1">{{$lang('厂家信息')}}：</view>
                        <view class="list">
                            <view class="li">{{$lang('供应商名称')}}：{{supplier.name}}</view>
                            <view class="li">{{$lang('供应商代码')}}：{{supplier.code}}</view>
                            <view class="li">{{$lang('供应商地址')}}：{{supplier.address}}</view>
                            <view class="li">{{$lang('供应商银行')}}：{{supplier.bank}}</view>
                            <view class="li">{{$lang('联系方式')}}：{{supplier.contact}}</view>
                        </view>
                    </view>
                </uni-forms>
            </view>
        </view>
        <view class="footerFen"></view>
        <view class="footer">
            <view class="top">
                <view class="fl" @click="$common.back()">{{$lang('取消')}}</view>
                <view class="fr" @click="submit">{{$lang('发起采购审批')}}</view>
            </view>
        </view>
        <u-picker
                :show="pickerShow"
                :columns="pickerColumns"
                @close="pickerShow = false"
                @cancel="pickerShow = false"
                @confirm="pickerConfirm"
                :keyName="keyName"
                closeOnClickOverlay
        ></u-picker>
    </view>
</template>

<script>
    import {
        purchaseInternalInquiryList,
        purchaseOrderList,
        purchaseInternalInquiryGoodsCode,
        productOwnershipOther,
        purchaseInternalAdd,
        internalList
    } from '../../api/api'
    export default {
        data() {
            return {
                baseUrl:'',
                ruleForm:{
                    mold:1,
                    mold_id:'',
                    mold_name:'',
                    order_id:'',
                    order_name:'',
                    list:[]
                },
                rules:{
                    mold: {
                        rules: [
                            { required: true, errorMessage: this.$lang('请选择类型') }
                        ]
                    },
                    mold_name: {
                        rules: [
                            { required: true, errorMessage: this.$lang('请选择询价单') }
                        ]
                    },
                    code: {
                        rules: [
                            { required: true, errorMessage: this.$lang('请输入采购单编码') }
                        ]
                    },
                    required: {
                        rules: [
                            { required: true, errorMessage: this.$lang('请输入') }
                        ]
                    },
                },
                radioList:[
                    { text: this.$lang('选择询价单号'), value: 1},
                    { text: this.$lang('关联采购单号'), value: 2},
                ],
                pickerShow:false,
                pickerColumns:[],
                type:'',
                keyName:'',
                tableColumn:[
                    {label:this.$lang('序号'),value:'index'},
                    {label:this.$lang('一级分类'),value:'category_one_name'},
                    {label:this.$lang('二级分类'),value:'category_two_name'},
                    {label:this.$lang('三级分类'),value:'category_three_name'},
                    {label:this.$lang('四级分类'),value:'category_four_name'},
                    {label:this.$lang('商品代码'),value:'goods_code'},
                    {label:this.$lang('尺寸mm'),value:'size'},
                    {label:this.$lang('图片'),value:'image'},
                    {label:this.$lang('数量'),value:'num'},
                    {label:this.$lang('单位'),value:'unit'},
                    {label:this.$lang('上次采购单价CNY'),value:'before_unit_price'},
                    {label:this.$lang('进货单价CNY'),value:'purchase_unit_price'},
                    {label:this.$lang('总价CNY'),value:'all_price'},
                    {label:this.$lang('单品体积m3'),value:'volume'},
                    {label:this.$lang('运费均摊OMR'),value:'freight'},
                    {label:this.$lang('估算进货单价OMR'),value:'estimated_purchase_price'},
                    {label:this.$lang('毛利率'),value:'gross_margin'},
                    {label:this.$lang('建议标价OMR'),value:'advise_price'},
                    {label:this.$lang('最低售价OMR'),value:'lowest_selling_price'},
                    {label:this.$lang('系统最低售价OMR'),value:'system_lowest_selling_price'},
                    {label:this.$lang('产品属性'),value:'product_attributes'},
                    {label:this.$lang('产品归属'),value:'product_ownership_id'},
                    {label:this.$lang('交货天数'),value:'deliveryday'},
                    {label:this.$lang('装柜天数'),value:'loadingday'},
                    {label:this.$lang('海运周期'),value:'shipping_cycle'},
                    {label:this.$lang('清关出样'),value:'customs_clearance_and_sample_production'},
                    {label:this.$lang('到货周期'),value:'delivery_cycle'},
                    {label:this.$lang('可销售库存'),value:'sellable_inventory'},
                    {label:this.$lang('维修库数量'),value:'number_of_maintenance_warehouses'},
                    {label:this.$lang('上次到货时间'),value:'last_delivery_time'},
                    {label:this.$lang('上次到货至今销量'),value:'sales_since_last_arrival'},
                    {label:this.$lang('未完成订单销量'),value:'unfinished_order_sales'},
                    {label:this.$lang('在途数量'),value:'quantity_in_transit'},
                    {label:this.$lang('在途采购日期'),value:'purchase_date_in_transit'},
                    {label:this.$lang('在途预计到港时间'),value:'expected_arrival_time_during_transit'},
                    {label:this.$lang('安全库存数量'),value:'safety_stock_quantity'},
                    {label:this.$lang('估算月销量'),value:'estimate_monthly_sales_volume'},
                    {label:this.$lang('销售数据一月前'),value:'one_data'},
                    {label:this.$lang('销售数据二月前'),value:'two_data'},
                    {label:this.$lang('销售数据三月前'),value:'three_data'},
                    {label:this.$lang('销售数据四月前'),value:'four_data'},
                    {label:this.$lang('销售数据五月前'),value:'five_data'},
                    {label:this.$lang('销售数据六月前'),value:'six_data'},
                    {label:this.$lang('备注'),value:'memo'}
                ],
                selectIndex:'',
                supplier:''
            }
        },
        onLoad() {
            this.baseUrl = this.$config.baseUrl;
        },
        methods: {
            internalListFun(type){
                this.type = type;
                uni.showLoading({
                    title:'加载中',
                    mask:true
                })
                internalList().then(res => {
                    this.pickerColumns = []
                    this.pickerColumns.push(res.data);
                    this.pickerShow = true;
                    this.keyName = 'code';
                })
            },
            moldChange(e){
                this.ruleForm.mold_name = '';
                this.ruleForm.mold_id = '';
            },
            productOwnershipOtherFun(type,selectIndex){
                this.type = type;
                this.selectIndex = selectIndex;
                productOwnershipOther().then(res => {
                    this.pickerColumns = [];
                    this.pickerShow = true;
                    this.pickerColumns.push(res.data);
                    this.keyName = 'name';
                })
            },
            pickerConfirm(e){
                if(this.type == 1){
                    this.ruleForm.mold_id = e.value[0].id;
                    this.ruleForm.mold_name = e.value[0].code;
                    console.log(this.pickerColumns);
                    this.pickerColumns[0].forEach(item => {
                        console.log()
                        if(e.value[0].id == item.id){
                            this.supplier = item.supplier;
                        }
                    })
                    console.log(this.supplier);
                    purchaseInternalInquiryGoodsCode({
                        id:e.value[0].id
                    }).then(res => {
                        this.ruleForm.list = res.data;
                        this.ruleForm.list = this.ruleForm.list.map(item => {
                            // 先展开外层对象，再展开 goods 对象，合并到外层
                            const { goods, ...rest } = item;
                            return {
                                ...rest,
                                ...goods // 把 goods 里面的字段合并到外层
                            };
                        });
                        this.ruleForm.list.forEach(item => {
                            item.category_one_name = item.category_one.name;
                            item.category_two_name = item.category_two.name;
                            item.category_three_name = item.category_three.name;
                            item.category_four_name = item.category_four.name;
                            item.deliveryday = '';
                            item.loadingday = '';
                            item.shipping_cycle = '';
                            item.customs_clearance_and_sample_production = '';
                            item.delivery_cycle = '';
                            item.sellable_inventory = '';
                            item.number_of_maintenance_warehouses = '';
                            item.last_delivery_time = '';
                            item.sales_since_last_arrival = '';
                            item.unfinished_order_sales = '';
                            item.quantity_in_transit = '';
                            item.purchase_date_in_transit = '';
                            item.expected_arrival_time_during_transit = '';
                            item.safety_stock_quantity = '';
                            item.estimate_monthly_sales_volume = '';
                            item.one_data = '';
                            item.two_data = '';
                            item.three_data = '';
                            item.four_data = '';
                            item.five_data = '';
                            item.six_data = '';
                            item.memo = '';
                            this.$forceUpdate();
                        })
                        this.ruleForm.list = JSON.parse(JSON.stringify(this.ruleForm.list));
                    })
                } else if(this.type == 2){
                    this.ruleForm.order_id = e.value[0].id;
                    this.ruleForm.order_name = e.value[0].order_no;
                } else if(this.type == 3){
                    this.ruleForm.list[this.selectIndex].product_ownership_name = e.value[0].name;
                    this.ruleForm.list[this.selectIndex].product_ownership_id = e.value[0].id;
                } else if(this.type == 4){
                    this.ruleForm.mold_id = e.value[0].id;
                    this.ruleForm.mold_name = e.value[0].code;
                    this.pickerColumns[0].forEach(item => {
                        console.log(item.id,e.value[0].id);
                        if(item.id == e.value[0].id){
                            this.ruleForm.list = item.goods_list;
                            this.ruleForm.list.forEach(item => {
                                item.category_one_name = item.category_one.name;
                                item.category_two_name = item.category_two.name;
                                item.category_three_name = item.category_three.name;
                                item.category_four_name = item.category_four.name;
                            });
                            this.supplier = item.supplier;
                        }
                    })
                }
                this.pickerShow = false;
            },
            purchaseOrderListFun(type){
                this.pickerColumns = [];
                uni.showLoading({
                    title:'加载中',
                    mask:true
                })
                purchaseOrderList().then(res => {
                    uni.hideLoading();
                    if(res.data.length == 0){
                        return uni.showToast({
                            title:this.$lang('询价单编号暂无数据'),
                            icon:'none'
                        })
                    }
                    this.type = type;
                    this.pickerColumns.push(res.data);
                    this.pickerShow = true;
                    this.keyName = 'order_no';
                })
            },
            purchaseInternalInquiryListFun(type){
                this.pickerColumns = [];
                uni.showLoading({
                    title:'加载中',
                    mask:true
                })
                purchaseInternalInquiryList().then(res => {
                    uni.hideLoading();
                    if(res.data.length == 0){
                        return uni.showToast({
                            title:this.$lang('询价单编号暂无数据'),
                            icon:'none'
                        })
                    }
                    this.type = type;
                    this.pickerColumns.push(res.data);
                    this.pickerShow = true;
                    this.keyName = 'code';
                })
            },
            submit(){
                console.log(this.ruleForm);
                this.$refs.ruleForm.validate().then(res=>{
                    purchaseInternalAdd(this.ruleForm).then(res => {
                        if(res.code == 1){
                            uni.showToast({
                                title:this.$lang('新增成功'),
                                icon:'none'
                            });
                            setTimeout(() => {
                                this.$common.back();
                            },500)
                        } else{
                            uni.showToast({
                                title:res.msg,
                                icon:'none'
                            })
                        }
                    })
                }).catch(err =>{
                    console.log('表单错误信息：', err);
                })
            }
        }
    }
</script>
<style>
    page{
        background: #f5f5f5;
    }
</style>
<style lang="scss" scoped>
    .main{
        padding: 60rpx 24rpx 40rpx 24rpx;
        .form{
            .radio{
                /deep/ .checklist-box{
                    .checklist-content{
                        .checklist-text{
                            color: #222;
                            font-size: 32rpx;
                        }
                    }
                    &.is-checked{
                        .radio__inner{
                            border-color: #365aa6;
                            .radio__inner-icon{
                                background-color: #365aa6;
                            }
                        }
                        .checklist-content{
                            .checklist-text{
                                color: #365aa6;
                            }
                        }
                    }
                }
            }
            .select{
                display: flex;
                align-items: center;
                justify-content: space-between;
                .fl{
                    font-size: 32rpx;
                    color: #222;
                    width: 235rpx;
                }
                .fr{
                    flex: 1;
                    display: flex;
                    align-items: center;
                    position: relative;
                    height: 90rpx;
                    border: 1px solid #747474;
                    padding: 0 33rpx;
                    border-radius: 10rpx;
                    input{
                        font-size: 32rpx;
                        color: #222;
                        padding-right: 15rpx;
                    }
                    image{
                        width: 60rpx;
                        height: 60rpx;
                    }
                }
            }
            .info{
                padding-top: 50rpx;
                .h1{
                    display: flex;
                    align-items: center;
                    font-size: 32rpx;
                    color: #222;
                    &:before{
                        content: '';
                        width: 8rpx;
                        height: 30rpx;
                        border-radius: 8rpx;
                        background: #365aa6;
                        margin-right: 20rpx;
                    }
                }
                .list{
                    padding-left: 25rpx;
                    font-size: 28rpx;
                    line-height: 48rpx;
                    color: #222;
                    margin-top: 18rpx;
                }
            }
        }
    }
    .footerFen{
        height: 179rpx;
    }
    .footer{
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 24rpx 24rpx 45rpx 24rpx;
        background: #f5f5f5;
        .top{
            display: flex;
            align-items: center;
            justify-content: space-between;
            .fl{
                width: 280rpx;
                height: 90rpx;
                border-radius: 90rpx;
                text-align: center;
                line-height: 90rpx;
                font-size: 36rpx;
                color: #555;
                border: 1px solid #c9c9c9;
                background: #eee;
            }
            .fr{
                width: 400rpx;
                height: 90rpx;
                border-radius: 90rpx;
                text-align: center;
                line-height: 90rpx;
                background: #365aa6;
                color: #fff;
                font-size: 36rpx;
            }
        }
    }
</style>
